<%--
  Created by IntelliJ IDEA.
  User: 19238
  Date: 2021/11/11
  Time: 12:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id="ch">
</form>
</body>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r!=null) return unescape(r[2]);
        return null;
    }

    var id = getUrlParam("id");
    $(function (){
        $.ajax({
            "url":"/kaoShig_war_exploded/app/selDsId",
            "type":"get",
            "data":{
                "id":id
            },
            "dataType":"json",
            "success":function(r){
                var date = r.result["driverSchool"]
                var html = "";
                html='<h1>驾校信息修改</h1>'
                html+='驾校名称：<input type="text" id="name" value='+date.name+'><br/>'
                html+='所在城区：<select id="cityAreaId">'
                html+='<option value=1>芙蓉区</option>'
                html+='<option value=2>岳麓区</option>'
                html+='<option value=3>望城区</option>'
                html+='<option value=4>天心区</option>'
                html+='</select><br/>'
                html+=' 地址：<input type="text" id="address" value='+date.address+'><br/>'
                html+='电话：<input type="text" id="phone" value='+date.phone+'><br/>'
                html+=' <input type="button" onclick="xiugai()" value="修改"/>'
                html+='<input type="button" onclick="chongtian()" value="重填"/>'
                html+=' <input type="button" onclick="fanhui()" value="返回">'
                $('#ch').append(html);
            },
            "error":function(){
                alert("服务器错误");
            }
        });
    })
    function xiugai() {
        var name = $('#name').val();
        var address = $('#address').val();
        var phone = $('#phone').val();
        $.ajax({
            "url":"/kaoShig_war_exploded/app/updateDs",
            "type":"get",
            "data":{
                "id":id,
                "name":name,
                "cityAreaId":1,
                "address":address,
                "phone":phone
            },
            "dataType":"text",
            "success":function(r){
                if(r=="true"){
                    alert("修改成功")

                }else {
                    alert("修改失败")

                }
            },
            "error":function(){
                alert("服务器错误");
            }
        });
    }

        function chongtian() {
            $('#name').val("")
            $('#address').val("")
            $('#phone').val("")
        }

</script>
</html>